<template>
  <!-- 初始化的空白页模板，勿删 -->
  <view class="xxxxx_page" v-if="showPage">
    <!-- 轮播 -->
    <view class="banner_box"><Banner mark="index_banner" /></view>
    <Tabbar :currentTab="-1" :list="tabbarList" />
  </view>
</template>

<script>
import Tabbar from '@/pages/pagecomponents/base/tabbar.vue';
import Banner from '@/pages/pagecomponents/other/banner.vue';
export default {
  components: {
    Banner,
    Tabbar
  },
  data() {
    return {
      tabbarList: ['index', '12348', 'mine'],
      param: {
        type: 'News',
        order: '',
        page: 1,
        limit: 10,
        search: ''
      },
    };
  },
  computed: {
    showPage() {
      // 页面是否已完成初始化
      return this.$store.state.user.showPage;
    },
    userInfo() {
      return this.$store.state.user.userInfo;
    }
  },
  onReachBottom() {
    // 触底操作
    this.getListData();
  },
  onPullDownRefresh() {
    // 下拉刷新
    this.getInitData();
  },
  async onLoad(e) {
    await this.$utils.getUserInfo(e, 'login');
    this.getInitData();
  },
  onShow() {},
  methods: {
    getInitData() {
      // 获取最新内容
      this.$api.user.getNewsList({ flag: 'new', ...this.param }).then(res => {
        uni.stopPullDownRefresh(); // 停止下拉刷新
        this.newsList = res.data.data;
      });
    }
  }
};
</script>

<style scoped lang="scss">
@import 'index.scss';
</style>
